// eslint-disable-next-line no-unused-vars
class WebNotification {
  static requestPermission() {
    let boolVal = false;
    boolVal = Notification.requestPermission().then(function(permission) {
      if (permission === "granted") {
        // console.debug("用户允许通知");
          //console.warn("user granted Notification.requestPermission");
        boolVal = true;
      } else if (permission === "denied") {
        // console.warn("user denied Notification.requestPermission");
        boolVal = false;
      }
      return boolVal;
    });
    return boolVal;
  }
  static build(options, callback) {
    const notificationOption = Object.assign({}, {
      title: "",
      body: "",
      data: {},
      silent: false,
      icon: "https://static.thebizark.com/assets/img/icons/bell_trans_512x512.png"
    },options);
    const myNotification = new Notification(
      notificationOption.title,
      notificationOption
    );
    if (callback) {
      myNotification.onclick = callback;
    }
    return myNotification;
  }
}
export { WebNotification };
export default WebNotification;
